
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include <iostream>
#include "camserver.h"

using namespace std;

#define DEFAULT_PORT 3000;

int main(int argc, char ** argv) {

#if wxUSE_UNICODE
    wxChar **wxArgv = new wxChar *[argc + 1];
    {
        int n;
        for (n = 0; n < argc; n++ ) {
            wxMB2WXbuf warg = wxConvertMB2WX(argv[n]);
            wxArgv[n] = wxStrdup(warg);
        }
        wxArgv[n] = NULL;
    }
#else // !wxUSE_UNICODE
    #define wxArgv argv
#endif // wxUSE_UNICODE/!wxUSE_UNICODE

    wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
    wxInitializer initializer;
    if ( !initializer )
    {
        fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
        return -1;
    }

	//wxInitialize(argc, (wxChar**)argv);

	//parse command line and initialize server configuration
	int port = 0;
	if (argc > 1) {
		port = atoi(argv[1]);
	} else {
		port = DEFAULT_PORT;
	}
	//start server
	CameraServer server(port);
	bool exitCode = server.start();
	//release variables
	wxUnusedVar(argc);
	wxUnusedVar(argv);
	return exitCode ? 0 : 1;
}
